Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tesla: Improve accuracy on temperature value #147

Merged
merged 2 commits into from
Jan 31, 2024

Conversation

dalathegreat
Copy link
Owner

@dalathegreat dalathegreat commented Jan 28, 2024

What

This PR improves the accuracy on the reported minimum/maximum temperature value read via CAN.

Why

Credit to frenetic over on the Discord server for noticing this bug!

How

The original calculation rounded every .5° downwards. For instance if battery temperature was 8.5C , the code reported back 8.0C

Old:
temp = rx_frame.data.u8[2]; max_temp = (temp * 0.5) - 40;

New:
max_temp = (rx_frame.data.u8[2] * 5) - 400;

Comment on lines 444 to 445
max_temp = (rx_frame.data.u8[2] * 5) - 400; //40.0*C offset, value for instance 85 = 8.5*C
min_temp = (rx_frame.data.u8[3] * 5) - 400; //40.0*C offset, value for instance 85 = 8.5*C
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A comment is needed to explain the reason for 5 multiplier and 40 degree offset.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment updated in 7f3c6ad

Software/src/battery/TESLA-MODEL-3-BATTERY.cpp Outdated Show resolved Hide resolved
@dalathegreat dalathegreat merged commit 01a17b8 into main Jan 31, 2024
34 checks passed
@dalathegreat dalathegreat deleted the bugfix/tesla-temperature-accuracy branch January 31, 2024 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants